package com.example.demospringmybatisplus.config;

import com.example.demospringmybatisplus.listener.InvoiceActionListenerManager;
import com.example.demospringmybatisplus.listener.InvoiceAddRetrieveActionListener;
import com.example.demospringmybatisplus.listener.InvoiceCancelActionListener;
import com.example.demospringmybatisplus.listener.InvoiceCreateActionListener;
import com.example.demospringmybatisplus.service.NotificationService;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 监听器配置类
 *
 * @author huahua
 * @DATE 2025/8/2
 **/
@Configuration
public class InvoiceActionListenerConfig {
    @Bean
    InvoiceActionListenerManager invoiceActionListenerManager() {
        return new InvoiceActionListenerManager();
    }

    @Bean
    public InvoiceAddRetrieveActionListener invoiceAddRetrieveActionListener(
        InvoiceActionListenerManager invoiceActionListenerManager, NotificationService notificationService) {
        InvoiceAddRetrieveActionListener invoiceAddRetrieveActionListener = new InvoiceAddRetrieveActionListener(
            notificationService);
        invoiceActionListenerManager.addListener(invoiceAddRetrieveActionListener);
        return invoiceAddRetrieveActionListener;
    }

    @Bean
    public InvoiceCancelActionListener invoiceCancelActionListener(
        InvoiceActionListenerManager invoiceActionListenerManager, NotificationService notificationService) {
        InvoiceCancelActionListener invoiceCancelActionListener = new InvoiceCancelActionListener(notificationService);
        invoiceActionListenerManager.addListener(invoiceCancelActionListener);
        return invoiceCancelActionListener;
    }

    @Bean
    public InvoiceCreateActionListener invoiceCreateActionListener(
        InvoiceActionListenerManager invoiceActionListenerManager, NotificationService notificationService) {
        InvoiceCreateActionListener invoiceCreateActionListener = new InvoiceCreateActionListener(notificationService);
        invoiceActionListenerManager.addListener(invoiceCreateActionListener);
        return invoiceCreateActionListener;
    }
}
